import { defineStore } from "pinia";

export const useCounterStore = defineStore("counter", {
  state: () => ({
    items: [
      { id: 1, sp:'电视',num: 1, price: 55 },
      { id: 2, sp:'手表',num: 1, price: 100 },
      { id: 3, sp:'平板',num: 1, price: 200 },
    ],
  }),
  actions: {
    jia(item) {
      item.num++;
    },
    jian(item) {
      if (item.num <= 0) {
        item.num === 0;
        return;
      }
      item.num--;
    },
  },
});
